package com.itheima.gui;

import javax.swing.*;

public class Test5 {

    public static void main(String[] args) {

        //BoxLayout 盒子布局
        JFrame jf = new JFrame("BoxLayout Example");
        jf.setSize(400,300);
        jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JPanel jp = new JPanel();
        jp.setLayout(new BoxLayout(jp,BoxLayout.Y_AXIS));       //垂直排列

        jp.add(new JButton("Button 1"));
        jp.add(Box.createVerticalStrut(10));        //添加垂直间隔
        jp.add(new JButton("Button 2"));
        jp.add(Box.createVerticalStrut(10));
        jp.add(new JButton("Button 3"));
        jp.add(Box.createVerticalStrut(10));
        jp.add(new JButton("Button 4"));
        jp.add(Box.createVerticalStrut(10));
        jp.add(new JButton("Button 5"));

        jf.add(jp);


        jf.setVisible(true);

    }
}
